Imports pixolut.BizBlox

Public Class Form1
    Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call
        Me.setupData()
    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    Friend WithEvents menuCreateDataset As System.Windows.Forms.MenuItem
    Friend WithEvents menuClearDataSet As System.Windows.Forms.MenuItem
    Friend WithEvents TabControl1 As System.Windows.Forms.TabControl
    Friend WithEvents chName As System.Windows.Forms.ColumnHeader
    Friend WithEvents chEmail As System.Windows.Forms.ColumnHeader
    Friend WithEvents chAge As System.Windows.Forms.ColumnHeader
    Friend WithEvents lvStudents As System.Windows.Forms.ListView
    Friend WithEvents tpStepOne As System.Windows.Forms.TabPage
    Friend WithEvents tpStepTwo As System.Windows.Forms.TabPage
    Friend WithEvents tpStepThree As System.Windows.Forms.TabPage
    Friend WithEvents tpStepFour As System.Windows.Forms.TabPage
    Friend WithEvents btLoadStudents As System.Windows.Forms.Button
    Friend WithEvents MainMenuTop As System.Windows.Forms.MainMenu
    Friend WithEvents menuResetData As System.Windows.Forms.MenuItem
    Friend WithEvents menuTools As System.Windows.Forms.MenuItem
    Friend WithEvents label6 As System.Windows.Forms.Label
    Friend WithEvents label4 As System.Windows.Forms.Label
    Friend WithEvents txSearchByEmail As System.Windows.Forms.TextBox
    Friend WithEvents label3 As System.Windows.Forms.Label
    Friend WithEvents label2 As System.Windows.Forms.Label
    Friend WithEvents btSearchStudents As System.Windows.Forms.Button
    Friend WithEvents Label1 As System.Windows.Forms.Label
    Friend WithEvents txSearchTermStudents As System.Windows.Forms.TextBox
    Friend WithEvents numAgeUpper As System.Windows.Forms.NumericUpDown
    Friend WithEvents numAgeLower As System.Windows.Forms.NumericUpDown
    Friend WithEvents ColumnHeader1 As System.Windows.Forms.ColumnHeader
    Friend WithEvents ColumnHeader2 As System.Windows.Forms.ColumnHeader
    Friend WithEvents ColumnHeader3 As System.Windows.Forms.ColumnHeader
    Friend WithEvents lvSearchStudents As System.Windows.Forms.ListView
    Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox
    Friend WithEvents cbFood As System.Windows.Forms.ComboBox
    Friend WithEvents Label5 As System.Windows.Forms.Label
    Friend WithEvents Label8 As System.Windows.Forms.Label
    Friend WithEvents txFoodPrice As System.Windows.Forms.TextBox
    Friend WithEvents Label10 As System.Windows.Forms.Label
    Friend WithEvents btSaveFood As System.Windows.Forms.Button
    Friend WithEvents txFoodName As System.Windows.Forms.TextBox
    Friend WithEvents btDeleteFood As System.Windows.Forms.Button
    Friend WithEvents Label12 As System.Windows.Forms.Label
    Friend WithEvents btSearchLunchOrders As System.Windows.Forms.Button
    Friend WithEvents Label13 As System.Windows.Forms.Label
    Friend WithEvents chLunchOrderDate As System.Windows.Forms.ColumnHeader
    Friend WithEvents chLunchOrderStudent As System.Windows.Forms.ColumnHeader
    Friend WithEvents chLunchOrderFood As System.Windows.Forms.ColumnHeader
    Friend WithEvents chLunchOrderQuantity As System.Windows.Forms.ColumnHeader
    Friend WithEvents chLunchOrderFoodPrice As System.Windows.Forms.ColumnHeader
    Friend WithEvents chLunchOrderTotal As System.Windows.Forms.ColumnHeader
    Friend WithEvents Label7 As System.Windows.Forms.Label
    Friend WithEvents Label9 As System.Windows.Forms.Label
    Friend WithEvents numFoodPriceUpper As System.Windows.Forms.NumericUpDown
    Friend WithEvents numFoodPriceLower As System.Windows.Forms.NumericUpDown
    Friend WithEvents cbLunchOrderEmail As System.Windows.Forms.ColumnHeader
    Friend WithEvents txStepFourEmail As System.Windows.Forms.TextBox
    Friend WithEvents lvLunchOrders As System.Windows.Forms.ListView
    Friend WithEvents Label14 As System.Windows.Forms.Label
    Friend WithEvents Label11 As System.Windows.Forms.Label
    Friend WithEvents Label15 As System.Windows.Forms.Label
    Friend WithEvents Label16 As System.Windows.Forms.Label
    Friend WithEvents Label17 As System.Windows.Forms.Label
    Friend WithEvents mnuHelp As System.Windows.Forms.MenuItem
    Friend WithEvents mnuAbout As System.Windows.Forms.MenuItem
    Friend WithEvents Label18 As System.Windows.Forms.Label
    Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.components = New System.ComponentModel.Container
        Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(Form1))
        Me.menuCreateDataset = New System.Windows.Forms.MenuItem
        Me.menuClearDataSet = New System.Windows.Forms.MenuItem
        Me.TabControl1 = New System.Windows.Forms.TabControl
        Me.tpStepOne = New System.Windows.Forms.TabPage
        Me.Label17 = New System.Windows.Forms.Label
        Me.Label11 = New System.Windows.Forms.Label
        Me.lvStudents = New System.Windows.Forms.ListView
        Me.chName = New System.Windows.Forms.ColumnHeader
        Me.chEmail = New System.Windows.Forms.ColumnHeader
        Me.chAge = New System.Windows.Forms.ColumnHeader
        Me.btLoadStudents = New System.Windows.Forms.Button
        Me.tpStepTwo = New System.Windows.Forms.TabPage
        Me.Label14 = New System.Windows.Forms.Label
        Me.lvSearchStudents = New System.Windows.Forms.ListView
        Me.ColumnHeader1 = New System.Windows.Forms.ColumnHeader
        Me.ColumnHeader2 = New System.Windows.Forms.ColumnHeader
        Me.ColumnHeader3 = New System.Windows.Forms.ColumnHeader
        Me.numAgeUpper = New System.Windows.Forms.NumericUpDown
        Me.numAgeLower = New System.Windows.Forms.NumericUpDown
        Me.label6 = New System.Windows.Forms.Label
        Me.label4 = New System.Windows.Forms.Label
        Me.txSearchByEmail = New System.Windows.Forms.TextBox
        Me.label3 = New System.Windows.Forms.Label
        Me.label2 = New System.Windows.Forms.Label
        Me.btSearchStudents = New System.Windows.Forms.Button
        Me.Label1 = New System.Windows.Forms.Label
        Me.txSearchTermStudents = New System.Windows.Forms.TextBox
        Me.tpStepThree = New System.Windows.Forms.TabPage
        Me.Label15 = New System.Windows.Forms.Label
        Me.Label5 = New System.Windows.Forms.Label
        Me.cbFood = New System.Windows.Forms.ComboBox
        Me.GroupBox1 = New System.Windows.Forms.GroupBox
        Me.TextBox1 = New System.Windows.Forms.TextBox
        Me.Label18 = New System.Windows.Forms.Label
        Me.Label8 = New System.Windows.Forms.Label
        Me.txFoodPrice = New System.Windows.Forms.TextBox
        Me.Label10 = New System.Windows.Forms.Label
        Me.btSaveFood = New System.Windows.Forms.Button
        Me.txFoodName = New System.Windows.Forms.TextBox
        Me.btDeleteFood = New System.Windows.Forms.Button
        Me.tpStepFour = New System.Windows.Forms.TabPage
        Me.Label16 = New System.Windows.Forms.Label
        Me.txStepFourEmail = New System.Windows.Forms.TextBox
        Me.numFoodPriceUpper = New System.Windows.Forms.NumericUpDown
        Me.numFoodPriceLower = New System.Windows.Forms.NumericUpDown
        Me.Label7 = New System.Windows.Forms.Label
        Me.Label9 = New System.Windows.Forms.Label
        Me.lvLunchOrders = New System.Windows.Forms.ListView
        Me.chLunchOrderDate = New System.Windows.Forms.ColumnHeader
        Me.chLunchOrderStudent = New System.Windows.Forms.ColumnHeader
        Me.cbLunchOrderEmail = New System.Windows.Forms.ColumnHeader
        Me.chLunchOrderFood = New System.Windows.Forms.ColumnHeader
        Me.chLunchOrderQuantity = New System.Windows.Forms.ColumnHeader
        Me.chLunchOrderFoodPrice = New System.Windows.Forms.ColumnHeader
        Me.chLunchOrderTotal = New System.Windows.Forms.ColumnHeader
        Me.Label12 = New System.Windows.Forms.Label
        Me.btSearchLunchOrders = New System.Windows.Forms.Button
        Me.Label13 = New System.Windows.Forms.Label
        Me.MainMenuTop = New System.Windows.Forms.MainMenu(Me.components)
        Me.menuTools = New System.Windows.Forms.MenuItem
        Me.menuResetData = New System.Windows.Forms.MenuItem
        Me.mnuHelp = New System.Windows.Forms.MenuItem
        Me.mnuAbout = New System.Windows.Forms.MenuItem
        Me.TabControl1.SuspendLayout()
        Me.tpStepOne.SuspendLayout()
        Me.tpStepTwo.SuspendLayout()
        CType(Me.numAgeUpper, System.ComponentModel.ISupportInitialize).BeginInit()
        CType(Me.numAgeLower, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.tpStepThree.SuspendLayout()
        Me.GroupBox1.SuspendLayout()
        Me.tpStepFour.SuspendLayout()
        CType(Me.numFoodPriceUpper, System.ComponentModel.ISupportInitialize).BeginInit()
        CType(Me.numFoodPriceLower, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.SuspendLayout()
        '
        'menuCreateDataset
        '
        Me.menuCreateDataset.Index = -1
        Me.menuCreateDataset.Text = "Create DataSet"
        '
        'menuClearDataSet
        '
        Me.menuClearDataSet.Index = -1
        Me.menuClearDataSet.Text = "Clear DataSet"
        '
        'TabControl1
        '
        Me.TabControl1.Controls.Add(Me.tpStepOne)
        Me.TabControl1.Controls.Add(Me.tpStepTwo)
        Me.TabControl1.Controls.Add(Me.tpStepThree)
        Me.TabControl1.Controls.Add(Me.tpStepFour)
        Me.TabControl1.Dock = System.Windows.Forms.DockStyle.Fill
        Me.TabControl1.Location = New System.Drawing.Point(0, 0)
        Me.TabControl1.Name = "TabControl1"
        Me.TabControl1.SelectedIndex = 0
        Me.TabControl1.Size = New System.Drawing.Size(560, 533)
        Me.TabControl1.TabIndex = 4
        '
        'tpStepOne
        '
        Me.tpStepOne.Controls.Add(Me.Label17)
        Me.tpStepOne.Controls.Add(Me.Label11)
        Me.tpStepOne.Controls.Add(Me.lvStudents)
        Me.tpStepOne.Controls.Add(Me.btLoadStudents)
        Me.tpStepOne.Location = New System.Drawing.Point(4, 22)
        Me.tpStepOne.Name = "tpStepOne"
        Me.tpStepOne.Size = New System.Drawing.Size(552, 507)
        Me.tpStepOne.TabIndex = 0
        Me.tpStepOne.Text = "Simple Binding"
        '
        'Label17
        '
        Me.Label17.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Label17.Location = New System.Drawing.Point(12, 68)
        Me.Label17.Name = "Label17"
        Me.Label17.Size = New System.Drawing.Size(144, 16)
        Me.Label17.TabIndex = 32
        Me.Label17.Text = "Load Students"
        '
        'Label11
        '
        Me.Label11.BackColor = System.Drawing.Color.LightSteelBlue
        Me.Label11.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.Label11.ForeColor = System.Drawing.Color.Navy
        Me.Label11.Location = New System.Drawing.Point(12, 12)
        Me.Label11.Name = "Label11"
        Me.Label11.Size = New System.Drawing.Size(528, 40)
        Me.Label11.TabIndex = 31
        Me.Label11.Text = "Example 1. This example demonstrates the most simple type of binding. Click 'Load" & _
            " Students' to Find All students in the database, and load their details into the" & _
            " ListBox."
        Me.Label11.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
        '
        'lvStudents
        '
        Me.lvStudents.Columns.AddRange(New System.Windows.Forms.ColumnHeader() {Me.chName, Me.chEmail, Me.chAge})
        Me.lvStudents.Location = New System.Drawing.Point(12, 128)
        Me.lvStudents.Name = "lvStudents"
        Me.lvStudents.Size = New System.Drawing.Size(528, 360)
        Me.lvStudents.TabIndex = 8
        Me.lvStudents.UseCompatibleStateImageBehavior = False
        Me.lvStudents.View = System.Windows.Forms.View.Details
        '
        'chName
        '
        Me.chName.Text = "Name"
        Me.chName.Width = 147
        '
        'chEmail
        '
        Me.chEmail.Text = "Email"
        Me.chEmail.Width = 154
        '
        'chAge
        '
        Me.chAge.Text = "Age"
        Me.chAge.Width = 214
        '
        'btLoadStudents
        '
        Me.btLoadStudents.Location = New System.Drawing.Point(12, 92)
        Me.btLoadStudents.Name = "btLoadStudents"
        Me.btLoadStudents.Size = New System.Drawing.Size(68, 24)
        Me.btLoadStudents.TabIndex = 4
        Me.btLoadStudents.Text = "Go"
        '
        'tpStepTwo
        '
        Me.tpStepTwo.Controls.Add(Me.Label14)
        Me.tpStepTwo.Controls.Add(Me.lvSearchStudents)
        Me.tpStepTwo.Controls.Add(Me.numAgeUpper)
        Me.tpStepTwo.Controls.Add(Me.numAgeLower)
        Me.tpStepTwo.Controls.Add(Me.label6)
        Me.tpStepTwo.Controls.Add(Me.label4)
        Me.tpStepTwo.Controls.Add(Me.txSearchByEmail)
        Me.tpStepTwo.Controls.Add(Me.label3)
        Me.tpStepTwo.Controls.Add(Me.label2)
        Me.tpStepTwo.Controls.Add(Me.btSearchStudents)
        Me.tpStepTwo.Controls.Add(Me.Label1)
        Me.tpStepTwo.Controls.Add(Me.txSearchTermStudents)
        Me.tpStepTwo.Location = New System.Drawing.Point(4, 22)
        Me.tpStepTwo.Name = "tpStepTwo"
        Me.tpStepTwo.Size = New System.Drawing.Size(552, 507)
        Me.tpStepTwo.TabIndex = 1
        Me.tpStepTwo.Text = "Searching"
        '
        'Label14
        '
        Me.Label14.BackColor = System.Drawing.Color.LightSteelBlue
        Me.Label14.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.Label14.ForeColor = System.Drawing.Color.Navy
        Me.Label14.Location = New System.Drawing.Point(12, 12)
        Me.Label14.Name = "Label14"
        Me.Label14.Size = New System.Drawing.Size(528, 40)
        Me.Label14.TabIndex = 30
        Me.Label14.Text = "Example 2. This example demonstrates how to use custom Find methods in a DOCollec" & _
            "tion to easily search and filter results. Enter some search parameters, and clic" & _
            "k Go. The name and email are optional."
        Me.Label14.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
        '
        'lvSearchStudents
        '
        Me.lvSearchStudents.Columns.AddRange(New System.Windows.Forms.ColumnHeader() {Me.ColumnHeader1, Me.ColumnHeader2, Me.ColumnHeader3})
        Me.lvSearchStudents.Location = New System.Drawing.Point(12, 232)
        Me.lvSearchStudents.Name = "lvSearchStudents"
        Me.lvSearchStudents.Size = New System.Drawing.Size(528, 260)
        Me.lvSearchStudents.TabIndex = 29
        Me.lvSearchStudents.UseCompatibleStateImageBehavior = False
        Me.lvSearchStudents.View = System.Windows.Forms.View.Details
        '
        'ColumnHeader1
        '
        Me.ColumnHeader1.Text = "Name"
        Me.ColumnHeader1.Width = 147
        '
        'ColumnHeader2
        '
        Me.ColumnHeader2.Text = "Email"
        Me.ColumnHeader2.Width = 154
        '
        'ColumnHeader3
        '
        Me.ColumnHeader3.Text = "Age"
        Me.ColumnHeader3.Width = 214
        '
        'numAgeUpper
        '
        Me.numAgeUpper.Location = New System.Drawing.Point(132, 156)
        Me.numAgeUpper.Name = "numAgeUpper"
        Me.numAgeUpper.Size = New System.Drawing.Size(48, 20)
        Me.numAgeUpper.TabIndex = 28
        Me.numAgeUpper.Value = New Decimal(New Integer() {50, 0, 0, 0})
        '
        'numAgeLower
        '
        Me.numAgeLower.Location = New System.Drawing.Point(56, 156)
        Me.numAgeLower.Name = "numAgeLower"
        Me.numAgeLower.Size = New System.Drawing.Size(48, 20)
        Me.numAgeLower.TabIndex = 27
        '
        'label6
        '
        Me.label6.Location = New System.Drawing.Point(108, 160)
        Me.label6.Name = "label6"
        Me.label6.Size = New System.Drawing.Size(24, 16)
        Me.label6.TabIndex = 26
        Me.label6.Text = "to"
        '
        'label4
        '
        Me.label4.Location = New System.Drawing.Point(8, 124)
        Me.label4.Name = "label4"
        Me.label4.Size = New System.Drawing.Size(40, 23)
        Me.label4.TabIndex = 25
        Me.label4.Text = "Email:"
        Me.label4.TextAlign = System.Drawing.ContentAlignment.TopRight
        '
        'txSearchByEmail
        '
        Me.txSearchByEmail.Location = New System.Drawing.Point(56, 124)
        Me.txSearchByEmail.Name = "txSearchByEmail"
        Me.txSearchByEmail.Size = New System.Drawing.Size(176, 20)
        Me.txSearchByEmail.TabIndex = 24
        '
        'label3
        '
        Me.label3.Location = New System.Drawing.Point(8, 160)
        Me.label3.Name = "label3"
        Me.label3.Size = New System.Drawing.Size(40, 16)
        Me.label3.TabIndex = 23
        Me.label3.Text = "Age:"
        Me.label3.TextAlign = System.Drawing.ContentAlignment.TopRight
        '
        'label2
        '
        Me.label2.Location = New System.Drawing.Point(8, 92)
        Me.label2.Name = "label2"
        Me.label2.Size = New System.Drawing.Size(40, 23)
        Me.label2.TabIndex = 22
        Me.label2.Text = "Name:"
        Me.label2.TextAlign = System.Drawing.ContentAlignment.TopRight
        '
        'btSearchStudents
        '
        Me.btSearchStudents.Location = New System.Drawing.Point(12, 192)
        Me.btSearchStudents.Name = "btSearchStudents"
        Me.btSearchStudents.Size = New System.Drawing.Size(64, 24)
        Me.btSearchStudents.TabIndex = 20
        Me.btSearchStudents.Text = "Go"
        '
        'Label1
        '
        Me.Label1.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Label1.Location = New System.Drawing.Point(8, 68)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(144, 16)
        Me.Label1.TabIndex = 19
        Me.Label1.Text = "Search Students"
        '
        'txSearchTermStudents
        '
        Me.txSearchTermStudents.Location = New System.Drawing.Point(56, 92)
        Me.txSearchTermStudents.Name = "txSearchTermStudents"
        Me.txSearchTermStudents.Size = New System.Drawing.Size(176, 20)
        Me.txSearchTermStudents.TabIndex = 18
        '
        'tpStepThree
        '
        Me.tpStepThree.Controls.Add(Me.Label15)
        Me.tpStepThree.Controls.Add(Me.Label5)
        Me.tpStepThree.Controls.Add(Me.cbFood)
        Me.tpStepThree.Controls.Add(Me.GroupBox1)
        Me.tpStepThree.Location = New System.Drawing.Point(4, 22)
        Me.tpStepThree.Name = "tpStepThree"
        Me.tpStepThree.Size = New System.Drawing.Size(552, 507)
        Me.tpStepThree.TabIndex = 2
        Me.tpStepThree.Text = "Editing"
        '
        'Label15
        '
        Me.Label15.BackColor = System.Drawing.Color.LightSteelBlue
        Me.Label15.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.Label15.ForeColor = System.Drawing.Color.Navy
        Me.Label15.Location = New System.Drawing.Point(12, 12)
        Me.Label15.Name = "Label15"
        Me.Label15.Size = New System.Drawing.Size(528, 40)
        Me.Label15.TabIndex = 31
        Me.Label15.Text = "Example 3. This example demonstrates three concepts: 1. How to bind data to a Con" & _
            "trol (the Food ComboBox), 2. How to add, edit and update data, 3. How to delete " & _
            "data."
        Me.Label15.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
        '
        'Label5
        '
        Me.Label5.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Label5.Location = New System.Drawing.Point(16, 68)
        Me.Label5.Name = "Label5"
        Me.Label5.Size = New System.Drawing.Size(100, 16)
        Me.Label5.TabIndex = 2
        Me.Label5.Text = "Select a Food"
        '
        'cbFood
        '
        Me.cbFood.Location = New System.Drawing.Point(16, 92)
        Me.cbFood.Name = "cbFood"
        Me.cbFood.Size = New System.Drawing.Size(240, 21)
        Me.cbFood.TabIndex = 1
        '
        'GroupBox1
        '
        Me.GroupBox1.Controls.Add(Me.TextBox1)
        Me.GroupBox1.Controls.Add(Me.Label18)
        Me.GroupBox1.Controls.Add(Me.Label8)
        Me.GroupBox1.Controls.Add(Me.txFoodPrice)
        Me.GroupBox1.Controls.Add(Me.Label10)
        Me.GroupBox1.Controls.Add(Me.btSaveFood)
        Me.GroupBox1.Controls.Add(Me.txFoodName)
        Me.GroupBox1.Controls.Add(Me.btDeleteFood)
        Me.GroupBox1.Location = New System.Drawing.Point(16, 132)
        Me.GroupBox1.Name = "GroupBox1"
        Me.GroupBox1.Size = New System.Drawing.Size(520, 360)
        Me.GroupBox1.TabIndex = 0
        Me.GroupBox1.TabStop = False
        Me.GroupBox1.Text = "Edit Food"
        '
        'TextBox1
        '
        Me.TextBox1.Location = New System.Drawing.Point(84, 104)
        Me.TextBox1.Multiline = True
        Me.TextBox1.Name = "TextBox1"
        Me.TextBox1.Size = New System.Drawing.Size(176, 72)
        Me.TextBox1.TabIndex = 36
        '
        'Label18
        '
        Me.Label18.Location = New System.Drawing.Point(16, 108)
        Me.Label18.Name = "Label18"
        Me.Label18.Size = New System.Drawing.Size(68, 23)
        Me.Label18.TabIndex = 35
        Me.Label18.Text = "Description:"
        '
        'Label8
        '
        Me.Label8.Location = New System.Drawing.Point(16, 68)
        Me.Label8.Name = "Label8"
        Me.Label8.Size = New System.Drawing.Size(40, 23)
        Me.Label8.TabIndex = 34
        Me.Label8.Text = "Price:"
        Me.Label8.TextAlign = System.Drawing.ContentAlignment.TopRight
        '
        'txFoodPrice
        '
        Me.txFoodPrice.Location = New System.Drawing.Point(84, 64)
        Me.txFoodPrice.Name = "txFoodPrice"
        Me.txFoodPrice.Size = New System.Drawing.Size(176, 20)
        Me.txFoodPrice.TabIndex = 30
        '
        'Label10
        '
        Me.Label10.Location = New System.Drawing.Point(16, 36)
        Me.Label10.Name = "Label10"
        Me.Label10.Size = New System.Drawing.Size(40, 23)
        Me.Label10.TabIndex = 31
        Me.Label10.Text = "Name:"
        Me.Label10.TextAlign = System.Drawing.ContentAlignment.TopRight
        '
        'btSaveFood
        '
        Me.btSaveFood.Location = New System.Drawing.Point(24, 200)
        Me.btSaveFood.Name = "btSaveFood"
        Me.btSaveFood.Size = New System.Drawing.Size(64, 20)
        Me.btSaveFood.TabIndex = 31
        Me.btSaveFood.Text = "Save"
        '
        'txFoodName
        '
        Me.txFoodName.Location = New System.Drawing.Point(84, 32)
        Me.txFoodName.Name = "txFoodName"
        Me.txFoodName.Size = New System.Drawing.Size(176, 20)
        Me.txFoodName.TabIndex = 29
        '
        'btDeleteFood
        '
        Me.btDeleteFood.Location = New System.Drawing.Point(436, 196)
        Me.btDeleteFood.Name = "btDeleteFood"
        Me.btDeleteFood.Size = New System.Drawing.Size(64, 20)
        Me.btDeleteFood.TabIndex = 32
        Me.btDeleteFood.Text = "Delete"
        '
        'tpStepFour
        '
        Me.tpStepFour.Controls.Add(Me.Label16)
        Me.tpStepFour.Controls.Add(Me.txStepFourEmail)
        Me.tpStepFour.Controls.Add(Me.numFoodPriceUpper)
        Me.tpStepFour.Controls.Add(Me.numFoodPriceLower)
        Me.tpStepFour.Controls.Add(Me.Label7)
        Me.tpStepFour.Controls.Add(Me.Label9)
        Me.tpStepFour.Controls.Add(Me.lvLunchOrders)
        Me.tpStepFour.Controls.Add(Me.Label12)
        Me.tpStepFour.Controls.Add(Me.btSearchLunchOrders)
        Me.tpStepFour.Controls.Add(Me.Label13)
        Me.tpStepFour.Location = New System.Drawing.Point(4, 22)
        Me.tpStepFour.Name = "tpStepFour"
        Me.tpStepFour.Size = New System.Drawing.Size(552, 507)
        Me.tpStepFour.TabIndex = 3
        Me.tpStepFour.Text = "Joins"
        '
        'Label16
        '
        Me.Label16.BackColor = System.Drawing.Color.LightSteelBlue
        Me.Label16.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.Label16.ForeColor = System.Drawing.Color.Navy
        Me.Label16.Location = New System.Drawing.Point(12, 12)
        Me.Label16.Name = "Label16"
        Me.Label16.Size = New System.Drawing.Size(528, 40)
        Me.Label16.TabIndex = 47
        Me.Label16.Text = "Example 4. This example demonstrates an Inner Join over three database tables - L" & _
            "unchOrder, Student and Food. Enter a Student's email (optional), select a Food p" & _
            "rice range, and click Go."
        Me.Label16.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
        '
        'txStepFourEmail
        '
        Me.txStepFourEmail.Location = New System.Drawing.Point(60, 92)
        Me.txStepFourEmail.Name = "txStepFourEmail"
        Me.txStepFourEmail.Size = New System.Drawing.Size(176, 20)
        Me.txStepFourEmail.TabIndex = 46
        '
        'numFoodPriceUpper
        '
        Me.numFoodPriceUpper.DecimalPlaces = 2
        Me.numFoodPriceUpper.Location = New System.Drawing.Point(140, 124)
        Me.numFoodPriceUpper.Name = "numFoodPriceUpper"
        Me.numFoodPriceUpper.Size = New System.Drawing.Size(60, 20)
        Me.numFoodPriceUpper.TabIndex = 45
        Me.numFoodPriceUpper.Value = New Decimal(New Integer() {50, 0, 0, 0})
        '
        'numFoodPriceLower
        '
        Me.numFoodPriceLower.DecimalPlaces = 2
        Me.numFoodPriceLower.Location = New System.Drawing.Point(60, 124)
        Me.numFoodPriceLower.Name = "numFoodPriceLower"
        Me.numFoodPriceLower.Size = New System.Drawing.Size(56, 20)
        Me.numFoodPriceLower.TabIndex = 44
        '
        'Label7
        '
        Me.Label7.Location = New System.Drawing.Point(120, 128)
        Me.Label7.Name = "Label7"
        Me.Label7.Size = New System.Drawing.Size(16, 16)
        Me.Label7.TabIndex = 43
        Me.Label7.Text = "to"
        '
        'Label9
        '
        Me.Label9.Location = New System.Drawing.Point(12, 128)
        Me.Label9.Name = "Label9"
        Me.Label9.Size = New System.Drawing.Size(40, 16)
        Me.Label9.TabIndex = 42
        Me.Label9.Text = "Price:"
        Me.Label9.TextAlign = System.Drawing.ContentAlignment.TopRight
        '
        'lvLunchOrders
        '
        Me.lvLunchOrders.Columns.AddRange(New System.Windows.Forms.ColumnHeader() {Me.chLunchOrderDate, Me.chLunchOrderStudent, Me.cbLunchOrderEmail, Me.chLunchOrderFood, Me.chLunchOrderQuantity, Me.chLunchOrderFoodPrice, Me.chLunchOrderTotal})
        Me.lvLunchOrders.Location = New System.Drawing.Point(12, 200)
        Me.lvLunchOrders.Name = "lvLunchOrders"
        Me.lvLunchOrders.Size = New System.Drawing.Size(528, 292)
        Me.lvLunchOrders.TabIndex = 41
        Me.lvLunchOrders.UseCompatibleStateImageBehavior = False
        Me.lvLunchOrders.View = System.Windows.Forms.View.Details
        '
        'chLunchOrderDate
        '
        Me.chLunchOrderDate.Text = "Date"
        Me.chLunchOrderDate.Width = 69
        '
        'chLunchOrderStudent
        '
        Me.chLunchOrderStudent.Text = "Student"
        Me.chLunchOrderStudent.Width = 72
        '
        'cbLunchOrderEmail
        '
        Me.cbLunchOrderEmail.Text = "Email"
        Me.cbLunchOrderEmail.Width = 83
        '
        'chLunchOrderFood
        '
        Me.chLunchOrderFood.Text = "Food"
        Me.chLunchOrderFood.Width = 104
        '
        'chLunchOrderQuantity
        '
        Me.chLunchOrderQuantity.Text = "Quantity"
        Me.chLunchOrderQuantity.Width = 68
        '
        'chLunchOrderFoodPrice
        '
        Me.chLunchOrderFoodPrice.Text = "Food Price"
        Me.chLunchOrderFoodPrice.Width = 75
        '
        'chLunchOrderTotal
        '
        Me.chLunchOrderTotal.Text = "Total"
        Me.chLunchOrderTotal.Width = 89
        '
        'Label12
        '
        Me.Label12.Location = New System.Drawing.Point(12, 96)
        Me.Label12.Name = "Label12"
        Me.Label12.Size = New System.Drawing.Size(40, 23)
        Me.Label12.TabIndex = 32
        Me.Label12.Text = "Email:"
        Me.Label12.TextAlign = System.Drawing.ContentAlignment.TopRight
        '
        'btSearchLunchOrders
        '
        Me.btSearchLunchOrders.Location = New System.Drawing.Point(16, 160)
        Me.btSearchLunchOrders.Name = "btSearchLunchOrders"
        Me.btSearchLunchOrders.Size = New System.Drawing.Size(64, 24)
        Me.btSearchLunchOrders.TabIndex = 31
        Me.btSearchLunchOrders.Text = "Go"
        '
        'Label13
        '
        Me.Label13.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Label13.Location = New System.Drawing.Point(12, 68)
        Me.Label13.Name = "Label13"
        Me.Label13.Size = New System.Drawing.Size(144, 16)
        Me.Label13.TabIndex = 30
        Me.Label13.Text = "Search Lunch Orders"
        '
        'MainMenuTop
        '
        Me.MainMenuTop.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.menuTools, Me.mnuHelp})
        '
        'menuTools
        '
        Me.menuTools.Index = 0
        Me.menuTools.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.menuResetData})
        Me.menuTools.Text = "Tools"
        '
        'menuResetData
        '
        Me.menuResetData.Index = 0
        Me.menuResetData.Text = "Reset Data"
        '
        'mnuHelp
        '
        Me.mnuHelp.Index = 1
        Me.mnuHelp.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuAbout})
        Me.mnuHelp.Text = "Help"
        '
        'mnuAbout
        '
        Me.mnuAbout.Index = 0
        Me.mnuAbout.Text = "About"
        '
        'Form1
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(560, 533)
        Me.Controls.Add(Me.TabControl1)
        Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
        Me.Menu = Me.MainMenuTop
        Me.Name = "Form1"
        Me.Text = "BizBlox Examples"
        Me.TabControl1.ResumeLayout(False)
        Me.tpStepOne.ResumeLayout(False)
        Me.tpStepTwo.ResumeLayout(False)
        Me.tpStepTwo.PerformLayout()
        CType(Me.numAgeUpper, System.ComponentModel.ISupportInitialize).EndInit()
        CType(Me.numAgeLower, System.ComponentModel.ISupportInitialize).EndInit()
        Me.tpStepThree.ResumeLayout(False)
        Me.GroupBox1.ResumeLayout(False)
        Me.GroupBox1.PerformLayout()
        Me.tpStepFour.ResumeLayout(False)
        Me.tpStepFour.PerformLayout()
        CType(Me.numFoodPriceUpper, System.ComponentModel.ISupportInitialize).EndInit()
        CType(Me.numFoodPriceLower, System.ComponentModel.ISupportInitialize).EndInit()
        Me.ResumeLayout(False)

    End Sub

#End Region


#Region "Setup and Menu"

    Private Sub setupData()
        Try
            Dim sColl As New StudentCollection
            sColl.FindAll()
            If sColl.Count = 0 Then
                Setup.CreateDataSet()
            End If
        Catch ex As Exception
            MessageBox.Show("BizBlox was unable to connect to the database. Please check the settings in the app.config file." & vbCrLf & vbCrLf & "Connection string used: " & vbCrLf & DSNManager.GetConnectionString, "Could not connect to database", MessageBoxButtons.OK, MessageBoxIcon.Error)
            Application.Exit()
        End Try
        Me.BindFoodTypes()
    End Sub

    Private Sub menuResetData_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles menuResetData.Click
        Cursor.Current = Cursors.WaitCursor
        Setup.ClearDataSet()
        Setup.CreateDataSet()
        Me.BindFoodTypes()
        Cursor.Current = Cursors.Default
    End Sub

    Private Sub mnuAbout_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuAbout.Click
        Dim a As New About
        a.Show()
    End Sub

#End Region


#Region "Simple Binding"

    Private Sub btLoadStudents_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btLoadStudents.Click
        Me.LoadStudents()
    End Sub

    Private Sub LoadStudents()
        Cursor.Current = Cursors.WaitCursor
        Me.lvStudents.Items.Clear()
        Dim sColl As New StudentCollection
        sColl.FindAll()
        For i As Integer = 0 To sColl.Count - 1
            Dim sObj As Student = sColl(i)
            Dim lvi As New ListViewItem(New String() {sObj.Name, sObj.Email, sObj.Age})
            Me.lvStudents.Items.Add(lvi)
        Next
        Cursor.Current = Cursors.Default
    End Sub

#End Region

#Region "Searching"

    Private Sub btSearchStudents_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btSearchStudents.Click
        Cursor.Current = Cursors.WaitCursor
        Me.lvSearchStudents.Items.Clear()
        Dim sCol As New StudentCollection
        sCol.FindByNameEmailAge(txSearchTermStudents.Text, txSearchByEmail.Text, Me.numAgeLower.Value, Me.numAgeUpper.Value)
        For i As Integer = 0 To sCol.Count - 1
            Dim sObj As Student = sCol(i)
            Dim lvi As New ListViewItem(New String() {sObj.Name, sObj.Email, sObj.Age})
            Me.lvSearchStudents.Items.Add(lvi)
        Next
        Cursor.Current = Cursors.Default
    End Sub

#End Region

#Region "Editing"


    Private Sub BindFoodTypes()
        Dim fColl As New FoodCollection
        fColl.FindAll()
        fColl.BindDataSource(Food.Columns.Name, Me.cbFood, "Add New Food...")
        DoFoodSelected()
    End Sub

    Private Sub cbFood_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbFood.SelectedIndexChanged
        Me.DoFoodSelected()
    End Sub

    Private Sub DoFoodSelected()
        Try
            If Me.cbFood.SelectedValue = "-1" Then
                Me.txFoodName.Text = ""
                Me.txFoodPrice.Text = ""
                Me.btDeleteFood.Visible = False
            Else
                Dim foodId As Guid = New Guid(Me.cbFood.SelectedValue.ToString)
                Me.LoadFood(foodId)
                Me.btDeleteFood.Visible = True
            End If
        Catch ex As Exception
        End Try
    End Sub

    Private Sub LoadFood(ByVal foodId As Guid)
        Dim f As New DOFactory(GetType(Food))
        Dim fObj As Food = f.Retrieve(foodId)
        Me.txFoodName.Text = fObj.Name
        Me.txFoodPrice.Text = fObj.Price.ToString("0.00")
    End Sub

    Private Sub btDeleteFood_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btDeleteFood.Click
        Cursor.Current = Cursors.WaitCursor
        Dim dr As DialogResult = MessageBox.Show("Are you sure you want to delete this food, and all lunch orders involving this food?", "Confirm deletion", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1)
        If dr = DialogResult.Yes Then
            Dim foodId As Guid = New Guid(Me.cbFood.SelectedValue.ToString)
            Dim loColl As New LunchOrderCollection
            loColl.FindByFood(foodId)
            loColl.Delete()
            Dim f As New DOFactory(GetType(Food))
            Dim fObj As Food = f.Retrieve(foodId)
            fObj.Delete()
            Me.BindFoodTypes()
        End If
        Cursor.Current = Cursors.Default
    End Sub

    Private Sub btSaveFood_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btSaveFood.Click
        Cursor.Current = Cursors.WaitCursor

        'Validate input data
        If Me.txFoodName.Text = "" Then
            MessageBox.Show("Please enter a valid name.")
            Return
        End If
        Dim price As Double = 0
        Try
            price = Double.Parse(Me.txFoodPrice.Text)
        Catch ex As Exception
            MessageBox.Show("Please enter a valid price.")
            Return
        End Try

        Dim f As New DOFactory(GetType(Food))
        Dim fObj As Food
        Dim message As String = ""

        If Me.cbFood.SelectedValue = "-1" Then
            'Adding a new food
            fObj = f.Create
            message = Me.txFoodName.Text & " added!"
        Else
            'Updating an existing food
            Dim foodId As Guid = New Guid(Me.cbFood.SelectedValue.ToString)
            fObj = f.Retrieve(foodId)
            message = Me.txFoodName.Text & " updated!"
        End If

        'Update the Food properties, and Save
        fObj.Name = Me.txFoodName.Text
        fObj.Price = price
        fObj.Save()

        'Reset the view
        MessageBox.Show(message)
        Me.BindFoodTypes()
        Me.DoFoodSelected()
        Me.cbFood.SelectedValue = fObj.FoodID.ToString
        Cursor.Current = Cursors.Default
    End Sub

#End Region


#Region "Joins"

    Private Sub btSearchLunchOrders_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btSearchLunchOrders.Click
        Cursor.Current = Cursors.WaitCursor
        Me.lvLunchOrders.Items.Clear()
        Dim loColl As New LunchOrderCollection
        loColl.FindByEmailAndPrice(Me.txStepFourEmail.Text, Me.numFoodPriceLower.Value, Me.numFoodPriceUpper.Value)
        For i As Integer = 0 To loColl.Count - 1
            Dim loObj As LunchOrder = loColl(i)
            Dim fObj As Food = loObj.GetByFoodID()
            Dim sObj As Student = loObj.GetByStudentID
            Dim total As String = (loObj.Quantity * fObj.Price).ToString("$0.00")
            Dim lvi As New ListViewItem(New String() {loObj.dt_OrderDate, sObj.Name, sObj.Email, fObj.Name, loObj.Quantity, fObj.Price.ToString("$0.00"), total})
            Me.lvLunchOrders.Items.Add(lvi)
        Next
        Cursor.Current = Cursors.Default
    End Sub

#End Region


    Private Sub UltraButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Dim fCol As New FoodCollection
        Dim mySql As SQLBuilder = fCol.GetSqlBuilder()
        mySql.addSelect(Food.Columns.Name)
        fCol.SetCurrentQuery(mySql)
        Dim test As Food = fCol(0)
    End Sub
End Class